import { request } from 'umi';
import { IloginItem } from '@/utils/interface';

// 用户数据
export const getUserShowUserUser = () => {
    return request('/user/user', { method: 'get' })
};
// 身份数据
export const getUserIdentity = () => {
    return request('/user/identity', { method: 'get' })
};
// api接口权限数据
export const getApi_authority = () => {
    return request('/user/api_authority', { method: 'get' })
};
// api接口权限数据
export const getIdentity_api_authority_relation = () => {
    return request('/user/identity_api_authority_relation', { method: 'get' })
};
// 获取视图权限数据
export const getView_authority = () => {
    return request('/user/view_authority', { method: 'get' })
};
// 给身份设定视图权限
export const getIdentity_view_authority_relation = () => {
    return request('/user/identity_view_authority_relation', { method: 'get' })
};
// 添加用户
interface datau{
    user_name:string,
    user_pwd:string,
    identity_id:string
}
export const setuser = (data:datau) => {
    return request('/user', {method: 'POST', data:{
        user_name:data.user_name,
        user_pwd:data.user_pwd,
        identity_id:data.identity_id
    }})
}; 
// 更新用户
interface datauu{
    user_id:string,
    user_name:string,
    user_pwd:string,
    identity_id:string
}
export const setuseruser = (data:datauu) => {
    console.log(data);
    return request('/user/user', {method: 'PUT',data})
}; 
// 添加身份
export const setIdentity = (identity_text:string) => {
    return request('/user/identity/edit', { method: 'GET', params: {identity_text}})
};
// 添加身份
interface datas{
    api_authority_text:string,
    api_authority_url:string,
    api_authority_method:string
}
export const setAuthorityApi = (data:datas) => {
    
    return request('/user/authorityApi/edit', {params: data})
};      
// 添加视图权限
interface datae{
    view_authority_text:string,
    view_id:string
}
export const setauthorityView = (data:datae) => {
    return request('/user/authorityView/edit', {params: data})
}; 
// 给身份设定api接口权限
interface datar{
    identity_id:string,
    api_authority_id:string
}
export const setsetIdentityApi = (data:datar) => {
    return request('/user/setIdentityApi', {method: 'POST',data})
}; 
// 给身份设定视图权限
interface datat{
    identity_id:string,
    view_authority_id:string
}
export const setsetIdentityView = (data:datat) => {
    // console.log(data);
    return request('/user/setIdentityView', {method: 'POST', data})
}; 
// 获取用户信息
export function getUserInfo(){
    return request('/user/userInfo')
}
